package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendUserQueryVO;
import com.tanhua.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/tanhua")


public class TanhuaController {
  @Autowired
    private TanhuaService tanhuaService;
/**
 * 今日佳人
 * GET /tanhua/todayBest
 */
  @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
      return tanhuaService.todayBest();
  }
  /**
   * 交友-推荐
   * GET /tanhua/recommendation
   */
  @GetMapping("/recommendation")
  public ResponseEntity recommendation(RecommendUserQueryVO queryVO){
    return tanhuaService.recommendation(queryVO);
  }
/**
 * 交友-查看佳人信息
 * GET /tanhua/:id/personalInfo
 */
  @GetMapping("/{id}/personalInfo")
  public  ResponseEntity personalInfo(@PathVariable("id") Long targetUserId){
    return tanhuaService.findPersonalInfo(targetUserId);
  }
  /**
   * 交友-查看陌生人问题
   * GET /tanhua/strangerQuestions
   */
  @GetMapping("/strangerQuestions")
  public  ResponseEntity findStrangerQuestion(Long userId){
    return tanhuaService.findStrangerQuestion(userId);
  }
  /**
   * 交友-回复陌生人问题
   * POST /tanhua/strangerQuestions
   */
  @PostMapping("/strangerQuestions")
  public ResponseEntity replyStrangerQuestion(@RequestBody Map map){
   Long targetUserId=Long.valueOf(map.get("userId").toString());
    String reply= (String)map.get("reply");
   return tanhuaService.replyStrangerQuestion(targetUserId,reply);
  }
  /**
   * 探花-搜附近
   * GET /tanhua/search
   */
  @GetMapping("/search")
  public ResponseEntity searchNear(@RequestParam(required = false) String gender,
                                   @RequestParam(defaultValue = "2000") Integer distance){
    return tanhuaService.searchNear(gender, distance);
  }
}
